# from selenium import webdriver
 
 
# # 登录百度
# def main():
#     global driver     # 设置全局变量
#     chromedriver_path =r"C:\Program Files\Google\Chrome\Application"
#     driver = webdriver.Chrome(chromedriver_path)
#     driver.get("https://baidu.com/")
 
 
# if __name__ == '__main__':
#     main()

# from selenium import webdriver
# driver = webdriver.Chrome()
# driver.get("http://www.baidu.com")
# driver.close()



# from selenium import webdriver
# import time

# class Grap:  # 类名应该以大写字母开头
#     def __init__(self):
#         self.driver = webdriver.Chorme()

#     def test(self):  # 将方法名改为 test
#         self.driver.get("https://www.baidu.com")
#         time.sleep(10)  # 等待10秒以便查看页面
#         self.driver.quit()

# if __name__ == "__main__":  # 注意这里的空格
#     g = Grap()  # 类名应为 Grap
#     g.test()  # 调用 test 方法


# from selenium import webdriver
# import time
# class Grap:
#     def __init__(self):
#         # Make sure the path to chromedriver is correct
#         self.driver = webdriver.Chrome(executable_path='C:\Program Files\Google\Chrome\Application\chromedriver.exe')

#     def close(self):
#         self.driver.quit()

# if __name__ == "__main__":
#     g = Grap()  # Instantiate the class
#     # Add any additional logic here
#     g.close()  # Close the browser when done

# from selenium import webdriver
# import time 
# import selenium.webdriver.chrome.service import Service


# class Grap:  # 类名应该以大写字母开头
#     def __init__(self):
#         self.server=Service(executable_path=r'C:\Program Files\Google\Chrome\Application\chromedriver.exe')
#         self.driver = webdriver.Chorme()

#     def test(self):  # 将方法名改为 test
#         self.driver.get("https://www.baidu.com")
#         time.sleep(10)  # 等待10秒以便查看页面
#         self.driver.quit()


# ; from selenium import webdriver
 
# ; chromedriver_path = r"C:\Users\AppData\Local\Google\Chrome\Application\chromedriver.exe"
# ; driver = webdriver.Chrome(chromedriver_path)
# ; # 登录百度
# ; def main():
# ;     driver.get("https://baidu.com/")
 
 
# ; if __name__ == '__main__':
# ;     main()
# from selenium import webdriver
# from selenium.webdriver.chorme.service import Service
# import time

# class Grap:  # 类名应该以大写字母开头
#     def __init__(self):
#         self.service = Service(r"C:\Users\AppData\Local\Google\Chrome\Application")  # 确保路径正确
#         self.driver = webdriver.Chorme(service=self.service)

#     def test(self):  # 方法名使用小写字母
#         self.driver.get("https://www.baidu.com")
#         self.driver.get("https://www.taobao.com")
#         self.driver.back(0)
#         self.driver.forward()
#         self.driver.refresh()
#         print("当前页面的标题：{}.format(self.driver.title")
#         print("当前页面的url：{}.format(self.driver.url")
#         self.driver.save_screenshot("taobao.png")
#         self.deiver.close()
#         self.deriver.quit()



#         print("当前页面的标题: {}".format(self.driver.title))
#         time.sleep(10)  # 等待10秒以便查看页面
#         self.driver.quit()

#get()打开一个网页
#back（）返回
#forward（）
#refresh（）
#save——screenshot（）截屏
#close（）关闭当前标签页
#quit（）关闭浏览器


# if __name__ == "__main__":  # 注意这里的空格
#     g = Grap()  # 类名应为 Grap
#     g.test()  # 调用 test 方法

# from selenium import webdriver
 
# chromedriver_path = r"C:\Program Files\Google\Chrome\Application\chromedriver.exe"
# driver = webdriver.Chrome(chromedriver_path)
# # 登录百度
# def main():
#     driver.get("https://baidu.com/")
 
 
# if __name__ == '__main__':
#     main()


from selenium import webdriver
from selenium.webdriver.chrome.service import Service
import time

class Grap:  # 类名应该以大写字母开头
    def __init__(self):
        # 设置驱动，selenium的新用法
        self.service = Service(r"C:\Program Files\Google\Chrome\Application\chromedriver.exe") 
        # 实例化浏览器对象
        self.driver = webdriver.Chrome(service=self.service)

    def test(self):  # 方法名使用小写字母
        self.driver.get("https://www.baidu.com")
        self.driver.get("https://www.taobao.com")
        self.driver.back(0)
        self.driver.forward()
        self.driver.refresh()
        print("当前页面的标题：{}.format(self.driver.title")
        print("当前页面的url：{}.format(self.driver.url")
        self.driver.save_screenshot("taobao.png")
        self.deiver.close()
        self.deriver.quit()



        print("当前页面的标题: {}".format(self.driver.title))
        time.sleep(10)  # 等待10秒以便查看页面
        self.driver.quit()

#get()打开一个网页
#back（）返回
#forward（）
#refresh（）
#save——screenshot（）截屏
#close（）关闭当前标签页
#quit（）关闭浏览器


if __name__ == "__main__":  # 注意这里的空格
    g = Grap()  # 类名应为 Grap
    g.test()  # 调用 test 方法

# from selenium import webdriver  
# driver = webdriver.Chrome()
